<?php
namespace app\front\controller;

use app\front\logic\CommonLogic;
use app\front\logic\ApiLogic;
use app\front\logic\LoginLogic;

class Login extends Base{
	//登录
    function login(){
    	$rs = LoginLogic::init()->toLogin();
        if($rs['code']>0){
            return ApiLogic::return($this->lang, $rs['code']); 
        }else{
            return ApiLogic::return($this->lang, $rs['code'], '', $rs['data']);
        }
    }

    //注册
    function register(){
        $rs = LoginLogic::init()->toRegister();
        return ApiLogic::return($this->lang, $rs);
    }

    //发送邮件验证码
    function sendEmail(){
        $rs = LoginLogic::init()->sendEmail();
        return ApiLogic::return($this->lang, $rs);
    }

    //找回密码
    function getBackPass(){
        $rs = LoginLogic::init()->getBackPass();
        return ApiLogic::return($this->lang, $rs);
    }

    function accountActive(){
        $rs = LoginLogic::init()->accountActive();
        return ApiLogic::return($this->lang, $rs);
    }

    //退出登录
    function logout(){
        LoginLogic::init()->logout();
    	return json(['code'=>0,'msg'=>'退出登录']);
    }
}
